package com.heima.controller;

import com.heima.pojo.dto.AddRegionDTO;
import com.heima.pojo.dto.ReceiveDto;
import com.heima.pojo.vo.PagingVO;
import com.heima.service.RegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/region")
@Slf4j
public class RegionController {
@Autowired
    private RegionService regionService;
    // 获取地区列表
    @GetMapping("/search")
    private PagingVO SelectRegion(ReceiveDto receiveDto){
        log.info("获取地区列表{}",receiveDto);
        PagingVO regionVO = regionService.SelectRegion(receiveDto);
        return regionVO;
    }
    //新增区域
    @PostMapping
    private Boolean addRegion(@RequestBody AddRegionDTO addRegionDTO){
        log.info("新增区域{}",addRegionDTO);
         return regionService.addRegion(addRegionDTO);

    }
    //删除区域
    @DeleteMapping("/{regionId}")
    private Boolean deleteRegion(@PathVariable String regionId){
        log.info("删除区域{}",regionId);
        return regionService.deleteRegion(regionId);
    }


}
